package com.example.zhxy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zhxy.model.Clazz;
import com.example.zhxy.model.Teacher;
import com.example.zhxy.service.TeacherService;
import com.example.zhxy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * ClassName: TeacherController
 * Package: com.example.zhxy.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-03-19
 * Time: 15:35
 */

@RestController
@RequestMapping("/sms/teacherController")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    //GET
    //http://localhost:9001/sms/teacherController/getTeachers/1/3?name=张&clazzName=一年一班
    //教师的分页查询
    @GetMapping("/getTeachers/{pageNo}/{pageSize}")
    public Result getTeacherPage(@PathVariable("pageNo") Integer pageNo,
                                 @PathVariable("pageSize") Integer pageSize,
                                 //name 教师姓名
                                 String name,String clazzName){
        //分页构造器
        Page<Teacher> page = new Page<>(pageNo,pageSize);

        //分页查询
        IPage<Teacher> iPage = teacherService.getTeacherPage(page,name,clazzName);


        return Result.ok(iPage);
    }

}
